import { defineStore } from 'pinia'
import { PositionList } from '../utils/trueType'
export const usePositionListStore = defineStore('positionList', {
    state: () => ({
        positionList: [
            {
                id: '',
                positionName: '',
                deptName: '',
                maxHeadcount: 0,
                currentHeadCount: 0,
                status: 1,
                time: ''
            }
        ] as PositionList[],
        selectedIds: <string[]>([]),
        loading: false,
        pageNum:1,
        pageSize:5,
        total:0
    }),
    actions: {
        setPositionList(positionList: PositionList[]) {
            this.positionList = positionList
        },
        changeLoading() {
            this.loading = !this.loading
            setTimeout(() => {
                this.loading = !this.loading
            }, 500);
        },
        addSelectedIds(id: string) {
            if (this.selectedIds.includes(id)) {
                this.selectedIds.splice(this.selectedIds.indexOf(id), 1)
            } else {
                this.selectedIds.push(id)
            }
        },
    },
    getters: {

    },
}
)